package org.example.sdk;

import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
import retrofit2.Retrofit;

@Component
public class ResourceApiFactory {

    private final ResourceApi resourceApi;

    public ResourceApiFactory() {
        Retrofit retrofit = getRetrofit();
        resourceApi = retrofit.create(ResourceApi.class);
    }

    @NotNull
    private Retrofit getRetrofit() {
        return new Retrofit.Builder()
                .baseUrl("http://localhost:8080")
                .addConverterFactory(new JsonNodeConverterFactory())
                .build();
    }

    public ResourceApi getResourceApi() {
        return resourceApi;
    }

}
